﻿using Common.Logging;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TopQuartz.UserJob
{
    /// <summary>
    /// 只需要将Job实现的dll拷贝到TopQuartz运行目前，配置TopQuartz/Configs/quartz_job.xml 便可运行
    ///  [DisallowConcurrentExecution] 表示阻塞执行
    /// </summary>
    [DisallowConcurrentExecution]
    public class MyJob : IJob
    {
        /// <summary>
        /// 日志记录
        /// 需要使用 Common.Logging 的相关日志类进行操作，TopQuartz/Configs/log4net.config 可配置日志记录情况
        /// </summary>
        private readonly ILog log = LogManager.GetLogger(typeof(MyJob));

        /// <summary>
        /// 配置参照
        /// </summary>
        /// <param name="context"></param>
        public void Execute(IJobExecutionContext context)
        {
            if (log.IsInfoEnabled)
            {
                log.InfoFormat("hi {0}!", context.JobDetail.JobDataMap["name"]);
            }
        }
    }
}
